package com.example.mylibrary.callback;
import com.example.mylibrary.exceptiopn.ApiException;

import io.reactivex.Observer;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;

public abstract class BaseObserver implements Observer {

    @Override
    public void onSubscribe(@NonNull Disposable d) {

    }

//    @Override
//    public void onNext(@NonNull Object o) {
//
//    }


    @Override
    public void onError(@NonNull Throwable e) {
        if (e instanceof ApiException){
            ApiException apiException= (ApiException) e;
            error(apiException.getMsg(),apiException.getCode());

        }


    }

    @Override
    public void onComplete() {

    }
    protected abstract void error(String error, int code);
}
